package com.example.demotest.repository;

import com.example.demotest.pojo.Complaint;
import com.example.demotest.pojo.Product;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ComplaintRepository extends JpaRepository<Complaint, Integer> {

    @Query("SELECT c FROM Complaint c WHERE c.complainant.userId = :userId")
    List<Complaint> findByComplainant(@Param("userId") Integer userId);

    @Query("SELECT c FROM Complaint c WHERE c.defendant.userId = :userId")
    List<Complaint> findByDefendant(@Param("userId") Integer userId);


    List<Complaint> findByReportedProduct(Product product);

}
